package org.come.Jpanel;

import org.apache.commons.lang.StringUtils;
import org.come.mouslisten.MsgPetDatilMouslisten;
import org.come.until.*;
import org.come.bean.ConfigureBean;
import org.come.bean.Skill;

import java.awt.*;
import java.awt.event.MouseListener;
import org.come.mouslisten.PetEquipMouslisten;
import com.gl.util.LingXiUtil;
import com.gl.util.Xy2Util;
import com.tool.pet.PetProperty;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;

import org.come.entity.RoleSummoning;
import org.come.model.Configure;

import io.netty.util.internal.StringUtil;

import com.tool.image.ImageMixDeal;
import java.awt.image.ImageObserver;
import java.util.List;
import javax.swing.*;

import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

import org.come.entity.Goodstable;

import com.tool.tcp.NewPart;
import com.tool.tcpimg.RichLabel;


public class PetsMsgJpanel extends JPanel {
    public static RoleSummoning roleSummoning;
    private int lock;
    private String type;
    private int gheight;
    private ImageIcon kaiqi;
    private ImageIcon kaiqi1;
    private ImageIcon qiling;
    private ImageIcon jzjy;
    private ImageIcon jzjy1;
    private JLabel qilingcount;
    private JLabel itemText;
    private JLabel[] labFive;
    private JLabel[] labPart;
    private JLabel[] labSkillImg;
    private JLabel[] labSkillName;
    private JLabel[] qlSkillImg;
    private JLabel[] qlSkillName;
    private RichLabel richLabel;
    private ImageIcon tianfu;
    private JLabel qlLab;
    //    private JLabel tfLab;
    private JLabel tianfucount;
    private NewPart part;
    public static ImageIcon icon;
    private ImageIcon shenshou1;
    private ImageIcon shenshou;
    private ImageIcon icon1;
    private List<Goodstable> nds;
    private Boolean jy = false;
    //召唤兽评分
    public static String petScore = "";
    private JLabel tsLabsc;
    public static ImageIcon petScoreicon0 = new ImageIcon("inkImg/number/id/petsc0.png");
    public static ImageIcon petScoreicon1 = new ImageIcon("inkImg/number/id/petsc1.png");
    public static ImageIcon petScoreicon2 = new ImageIcon("inkImg/number/id/petsc2.png");
    public static ImageIcon petScoreicon3 = new ImageIcon("inkImg/number/id/petsc3.png");
    public static ImageIcon petScoreicon4 = new ImageIcon("inkImg/number/id/petsc4.png");
    public static ImageIcon petScoreicon5 = new ImageIcon("inkImg/number/id/petsc5.png");
    public static ImageIcon petScoreicon6 = new ImageIcon("inkImg/number/id/petsc6.png");
    public static ImageIcon petScoreicon7 = new ImageIcon("inkImg/number/id/petsc7.png");
    public static ImageIcon petScoreicon8 = new ImageIcon("inkImg/number/id/petsc8.png");
    public static ImageIcon petScoreicon9 = new ImageIcon("inkImg/number/id/petsc9.png");

    private JLabel czDLab,hpDLab,mpDLab,spDLab,apDLab,hpzLab,mpzLab,spzLab,apzLab;

    public PetsMsgJpanel(final int gheight) {
        ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        Configure configure = item.get(new BigDecimal(1));
        int ndsl = 4;
        if(configure.getNdslsx()!=null) {
            ndsl = Integer.parseInt(configure.getNdslsx());
        }
        int numskll = 9;
        if(configure.getZhsjngs()!=null) {
            numskll = Integer.parseInt(configure.getZhsjngs());
        }

        this.lock = 0;
        this.type = "";
        this.shenshou1 = new ImageIcon("inkImg/hongmu/1/dingzhishenshou.png");
        this.icon1 = new ImageIcon("inkImg/hongmu/2/goodorpet_lock.png");
        this.kaiqi = new ImageIcon("inkImg/old/2/S156.png");
        this.shenshou = new ImageIcon("inkImg/old/background/6.png");
        this.kaiqi1 = new ImageIcon("inkImg/old/lingbao/msg/开.png");
//        this.tianfu = new ImageIcon("inkImg/hongmu/1/tianfu.png");
        this.qiling = new ImageIcon("inkImg/hongmu/1/qiling.png");
        this.jzjy = new ImageIcon("inkImg/old/1/禁交易.png");
        this.jzjy1 = new ImageIcon("inkImg/old/1/可交易.png");
//        this.jzjy = new ImageIcon("resource/mouse/禁交易.png");
        this.gheight = gheight;
        this.setPreferredSize(new Dimension(434, gheight));
        this.setLayout(null);
        this.setBackground(UIUtils.Color_BACK);
        (this.richLabel = new RichLabel("", UIUtils.TEXT_FONT1, 255)).setBounds(155, 10, this.richLabel.getWidth(), this.richLabel.getHeight());
        this.add((Component)this.richLabel);
        (this.qilingcount = new JLabel()).setForeground(Color.yellow);
        this.qilingcount.setBackground(UIUtils.Color_BACK);
        this.qilingcount.setFont(UIUtils.TEXT_FONT2);
        this.qilingcount.setBounds(68, 180, 40, 20);
        if(numskll == 9) {
            this.add((Component)this.qilingcount);
        }
        (this.qlLab = new JLabel()).setOpaque(true);
        this.qlLab.setBounds(10, 180, 50, 20);
        this.qlLab.setIcon((Icon)this.qiling);
        if(numskll == 9) {
            this.add((Component)this.qlLab);
        }

//        (this.tfLab = new JLabel()).setOpaque(true);
//        this.tfLab.setBounds(10, 200, 50, 20);
//        this.tfLab.setIcon((Icon)this.tianfu);
//        this.add((Component)this.tfLab);

//        (this.tianfucount = new JLabel()).setForeground(Color.yellow);
//        this.tianfucount.setBackground(UIUtils.Color_BACK);
//        this.tianfucount.setFont(UIUtils.TEXT_FONT2);
//        this.tianfucount.setBounds(68, 200, 40, 20);
//        this.add((Component)this.tianfucount);
//        this.tianfucount.setText("0阶");
        this.tsLabsc = new JLabel();
        this.tsLabsc.setForeground(UIUtils.COLOR_NAME2);
        this.tsLabsc.setFont(new Font("楷体",Font.BOLD, 20));
        this.add(this.tsLabsc);
        Color color = Color.decode("0xA49BC8");
        this.labFive = new JLabel[5];
        for (int i = 0; i < this.labFive.length; ++i) {
            (this.labFive[i] = new JLabel()).setForeground(color);
            this.labFive[i].setBackground(UIUtils.Color_BACK);
            this.labFive[i].setFont(UIUtils.TEXT_FONT1);
            this.add((Component)this.labFive[i]);
        }
        this.labPart = new JLabel[4];
        if(!"3".equals(Xy2Util.zzs)) {
            for (int i = 0; i < this.labPart.length; ++i) {
                this.add((Component)(this.labPart[i] = new JLabel() {
                    @Override
                    protected void paintComponent(final Graphics g) {
                        g.drawImage(PetsMsgJpanel.this.kaiqi1.getImage(), 0, 0, 26, 26, null);
                        g.translate(1, 1);
                        super.paintComponent(g);
                        g.translate(-1, -1);
                    }
                }));
            }
        }
        this.labSkillImg = new JLabel[numskll];
        this.labSkillName = new JLabel[numskll];
        color = Color.decode("0xA5B4F3");
        for (int i = 0; i < this.labSkillImg.length; ++i) {
            if(numskll==5) {
                (this.labSkillImg[i] = new JLabel()).setOpaque(true);
                this.labSkillImg[i].setBounds(10, 200 + i * 20, 20, 20);
                this.add((Component)this.labSkillImg[i]);
                (this.labSkillName[i] = new JLabel()).setForeground(color);
                this.labSkillName[i].setBackground(UIUtils.Color_BACK);
                this.labSkillName[i].setFont(UIUtils.TEXT_FONT1);
                this.labSkillName[i].setBounds(35, 200 + i * 20, 105, 20);
                this.add((Component)this.labSkillName[i]);
            }else if(numskll==7) {
                (this.labSkillImg[i] = new JLabel()).setOpaque(true);
                this.labSkillImg[i].setBounds(10, 200 + i * 20, 20, 20);
                this.add((Component)this.labSkillImg[i]);
                (this.labSkillName[i] = new JLabel()).setForeground(color);
                this.labSkillName[i].setBackground(UIUtils.Color_BACK);
                this.labSkillName[i].setFont(UIUtils.TEXT_FONT1);
                this.labSkillName[i].setBounds(35, 200 + i * 20, 105, 20);
                this.add((Component)this.labSkillName[i]);
            }else {
                (this.labSkillImg[i] = new JLabel()).setOpaque(true);
                this.labSkillImg[i].setBounds(10, 230 + i * 20, 20, 20);
                this.add((Component)this.labSkillImg[i]);
                (this.labSkillName[i] = new JLabel()).setForeground(color);
                this.labSkillName[i].setBackground(UIUtils.Color_BACK);
                this.labSkillName[i].setFont(UIUtils.TEXT_FONT1);
                this.labSkillName[i].setBounds(35, 230 + i * 20, 105, 20);
                this.add((Component)this.labSkillName[i]);
            }
        }
        this.qlSkillImg = new JLabel[6];
        this.qlSkillName = new JLabel[6];
        for (int i = 0; i < this.qlSkillImg.length; ++i) {
            (this.qlSkillImg[i] = new JLabel()).setOpaque(true);
            this.qlSkillImg[i].setBounds(10, 230 + i * 20, 20, 20);
            this.add((Component)this.qlSkillImg[i]);
            (this.qlSkillName[i] = new JLabel()).setForeground(Color.green);
            this.qlSkillName[i].setBackground(UIUtils.Color_BACK);
            this.qlSkillName[i].setFont(UIUtils.TEXT_FONT1);
            this.qlSkillName[i].setBounds(35, 230 + i * 20, 105, 20);
            this.add((Component)this.qlSkillName[i]);
        }
        this.tsLabsc = new JLabel();
        this.tsLabsc.setForeground(UIUtils.COLOR_NAME2);
        this.tsLabsc.setFont(new Font("楷体",Font.BOLD, 20));
        this.add(this.tsLabsc);



        czDLab = new JLabel();
        czDLab.setText("<html><u></u></html>");
        czDLab.setForeground(Color.white);
        czDLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        czDLab.addMouseListener(new MsgPetDatilMouslisten(1,this,1));
        add(czDLab);

        hpDLab = new JLabel();
        hpDLab.setText("<html><u></u></html>");
        hpDLab.setForeground(Color.white);
        hpDLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        hpDLab.addMouseListener(new MsgPetDatilMouslisten(1,this,2));
        add(hpDLab);

        mpDLab = new JLabel();
        mpDLab.setText("<html><u></u></html>");
        mpDLab.setForeground(Color.white);
        mpDLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        mpDLab.addMouseListener(new MsgPetDatilMouslisten(1,this,3));
        add(mpDLab);

        apDLab = new JLabel();
        apDLab.setText("<html><u></u></html>");
        apDLab.setForeground(Color.white);
        apDLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        apDLab.addMouseListener(new MsgPetDatilMouslisten(1,this,4));
        add(apDLab);

        spDLab = new JLabel();
        spDLab.setText("<html><u></u></html>");
        spDLab.setForeground(Color.white);
        spDLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        spDLab.addMouseListener(new MsgPetDatilMouslisten(1,this,5));
        add(spDLab);

        hpzLab = new JLabel();
        hpzLab.setText("");
        hpzLab.setForeground(hexToColor("#7DDE8C"));
        hpzLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        add(hpzLab);

        mpzLab = new JLabel();
        mpzLab.setText("");
        mpzLab.setForeground(hexToColor("#7DDE8C"));
        mpzLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        add(mpzLab);

        spzLab = new JLabel();
        spzLab.setText("");
        spzLab.setForeground(hexToColor("#7DDE8C"));
        spzLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        add(spzLab);

        apzLab = new JLabel();
        apzLab.setText("");
        apzLab.setForeground(hexToColor("#7DDE8C"));
        apzLab.setFont(new Font("微软雅体",Font.PLAIN, 14));
        add(apzLab);
    }

    @Override
    public void paint(final Graphics g) {
        if (PetsMsgJpanel.icon == null) {
            PetsMsgJpanel.icon = new ImageIcon("inkImg/newbackground/S301.png");
        }

        g.drawImage(PetsMsgJpanel.icon.getImage(), 0, 0, 434, this.gheight, (ImageObserver)this);
        super.paint(g);
        if (this.lock == 1) {
            g.drawImage(this.icon1.getImage(), 140, 15, 10, 12, (ImageObserver)this);
        }
        if (this.part != null) {
            this.part.draw(g, 85, 135, 0, ImageMixDeal.userimg.getTime());
        }
        if (StringUtil.isNullOrEmpty(this.type) || "2".equals(this.type) || "3".equals(this.type) || "4".equals(this.type)) {
            g.drawImage(this.shenshou.getImage(), 130 - this.shenshou.getIconWidth() - 85, 10, this.shenshou.getIconWidth(), this.shenshou.getIconHeight(), (ImageObserver)this);
        }
        if (!StringUtil.isNullOrEmpty(this.type) && "88".equals(this.type)) {
            g.drawImage(this.shenshou1.getImage(), 130 - this.shenshou1.getIconWidth() - 50, 10, this.shenshou1.getIconWidth(), this.shenshou1.getIconHeight(), (ImageObserver)this);
        }
//        if (this.jy) {
//            g.drawImage(this.jzjy1.getImage(), 340, 65, jzjy1.getIconWidth(), jzjy1.getIconHeight(), (ImageObserver)this);
//        }else{
//            g.drawImage(this.jzjy.getImage(), 340, 65, jzjy.getIconWidth(), jzjy.getIconHeight(), (ImageObserver)this);
//        }
        if(petScore!=null && petScore!="") {
            int sco = 247;
            int ysco = 21;
            for(int i=0;i<petScore.length();i++) {
                String scpre = petScore.charAt(i)+"";
                if(scpre.equals("0")) {
                    g.drawImage(petScoreicon0.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("1")) {
                    g.drawImage(petScoreicon1.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("2")) {
                    g.drawImage(petScoreicon2.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("3")) {
                    g.drawImage(petScoreicon3.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("4")) {
                    g.drawImage(petScoreicon4.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("5")) {
                    g.drawImage(petScoreicon5.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("6")) {
                    g.drawImage(petScoreicon6.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("7")) {
                    g.drawImage(petScoreicon7.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("8")) {
                    g.drawImage(petScoreicon8.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }else if(scpre.equals("9")) {
                    g.drawImage(petScoreicon9.getImage(), sco+i*14, 60-ysco, 22, 25, (ImageObserver)this);
                }
            }
        }
    }

    ConfigureBean allConfigure;
    Map<BigDecimal, Configure> item;
    Configure configure;
    int numskll = 9;
    int max = 75;
    Goodstable cjs = null;
    Goodstable part1 = null;
    Goodstable part2 = null;
    Goodstable part3 = null;
    Goodstable good;
    Goodstable good2 = null;
    BigDecimal rgid;
    Goodstable good3;
    Goodstable goodstable;
    String[] v;
    StringBuffer buffer;
    Configure configure7;
    String[] tss = null;
    String[] lys = null;
    String[] v2;
    int[] pets;
    int sizeW;
    int k;
    Goodstable good4;
    String[] strings;
    String[] stringLevel;
    String[] stringLevel2;
    String qz;
    String[] kx;
    Long qm;
    Goodstable good5;
    PetEquipMouslisten equipMouslisten2;
    int openSeal;
    String[] skills = null;
    String[] skillsx = null;
    Skill skillx;
    int[] array;
    int n = 0;
    int[] array2 ;
    int n2 ;


    public int petMsg(final RoleSummoning pet, final List<Goodstable> goods) {
        roleSummoning = pet;
        allConfigure = UserMessUntil.getConfigureBean();
        item = allConfigure.getAllConfigure();
        configure = item.get(new BigDecimal(1));
        jy = false;
        if("2".equals(pet.getQuality())){
            jy = true;
        }

        int numskll = 9;
        if(configure.getZhsjngs()!=null) {
            numskll = Integer.parseInt(configure.getZhsjngs());
        }

        int max = 75;
        if(configure.getZhskxsx()!=null && configure.getZhskxsx()!="") {
            max = 75+Integer.parseInt(configure.getZhskxsx());
        }

        this.lock = pet.getPetlock();
        this.part = pet.getPart();
        this.type = pet.getSsn();
        if (this.nds == null) {
            this.nds = (List<Goodstable>)new ArrayList();
        }
        else {
            this.nds.clear();
        }
        Goodstable cjs = null;
        Goodstable part1 = null;
        Goodstable part2 = null;
        Goodstable part3 = null;
        if (goods != null) {
            for (int i = 0; i < goods.size(); ++i) {
                final Goodstable good = (Goodstable)goods.get(i);
                if (good.getType().longValue() == 750L) {
                    this.nds.add(good);
                }
                else if (good.getType().longValue() == 729L) {
                    cjs = good;
                }
                else if (good.getType().longValue() == 510L) {
                    part1 = good;
                }
                else if (good.getType().longValue() == 511L) {
                    part2 = good;
                }
                else if (good.getType().longValue() == 512L) {
                    part3 = good;
                }
            }
        }
        else {
            if (pet.getStye() != null && pet.getStye().length() > 1) {
                final String[] v = pet.getStye().split("\\|");
                for (int j = 1; j < v.length; ++j) {
                    final String[] vs = v[j].split("-");
                    if (vs.length >= 2) {

                        good2 = null;
                        if(pet.getCjs()!=null && pet.getCjs().getRgid().compareTo(new BigDecimal(vs[1])) == 0){
                            good2 = pet.getCjs();
                        }
                        if(pet.getPart1()!=null && pet.getPart1().getRgid().compareTo(new BigDecimal(vs[1])) == 0){
                            good2 = pet.getPart1();
                        }
                        if(pet.getPart2()!=null && pet.getPart2().getRgid().compareTo(new BigDecimal(vs[1])) == 0){
                            good2 = pet.getPart2();
                        }
                        if(pet.getPart3()!=null && pet.getPart3().getRgid().compareTo(new BigDecimal(vs[1])) == 0){
                            good2 = pet.getPart3();
                        }
                        if(good2 == null){
                            good2 = GoodsListFromServerUntil.getRgid(new BigDecimal(vs[1]));
                        }

                        if (good2 != null) {
                            if (good2.getType().longValue() == 729L) {
                                cjs = good2;
                            }
                            else if (good2.getType().longValue() == 510L) {
                                part1 = good2;
                            }
                            else if (good2.getType().longValue() == 511L) {
                                part2 = good2;
                            }
                            else if (good2.getType().longValue() == 512L) {
                                part3 = good2;
                            }
                        }
                    }
                }
            }
            if (pet.getInnerGoods() != null && !"".equals(pet.getInnerGoods())) {
                v = pet.getInnerGoods().split("\\|");
                for (int j = 0; j < v.length; ++j) {
                    rgid = new BigDecimal(v[j]);
                    good3 = GoodsListFromServerUntil.getRgid(rgid);
                    if (good3 != null) {
                        this.nds.add(good3);
                    }else{
                        goodstable = pet.getNeiDan().get(rgid);
                        if(goodstable != null){
                            this.nds.add(goodstable);
                        }
                    }
                }
            }
        }
        final StringBuffer buffer = new StringBuffer();
        buffer.append("#W");
        buffer.append(pet.getSummoningname());
        buffer.append("   ");
        if (pet.getGrade().intValue() <= 100) {
            buffer.append("#c00FF00");
            buffer.append(AnalysisString.petLvl(pet.getGrade().intValue()));
        }
        else if (pet.getGrade().intValue() > 100 && pet.getGrade().intValue() <= 221) {
            buffer.append("#cFF8C00");
            buffer.append(AnalysisString.petLvl(pet.getGrade().intValue()));
        }
        else if (pet.getGrade().intValue() > 221 && pet.getGrade().intValue() <= 362) {
            buffer.append("#c00F5FF");
            buffer.append(AnalysisString.petLvl(pet.getGrade().intValue()));
        }
        else if (pet.getGrade().intValue() > 362 && pet.getGrade().intValue() <= 543) {
            buffer.append("#cEE2C2C");
            buffer.append(AnalysisString.petLvl(pet.getGrade().intValue()));
        }
        else {
            buffer.append("#c8A2BE2");
            buffer.append(AnalysisString.petLvl(pet.getGrade().intValue()));
        }

        if(pet.getQuality()!=null) {
            if(!"2".equals(pet.getQuality())) {
                buffer.append("#cEE2C2C");
                buffer.append("\t  禁止交易");
            }
        }
        if(pet.getQuality()!=null) {
            if("1".equals(pet.getQuality())) {
                if(pet.getSurplusTimes()!=null) {
                    buffer.append("#r#cEE2C2C过期时间："+pet.getSurplusTimes());
                    buffer.append("#r ");
                }
            }
        }
        petScore = PetScoreUtil.addCountPetScore(pet);
        this.tsLabsc.setText("战力评分：" + petScore);
        this.tsLabsc.setBounds(150, 10, 180, 80);
        this.tsLabsc.setVisible(true);
        buffer.append("#r ");
        buffer.append("#r ");
        buffer.append("#r ");
        buffer.append("#r#cFBFFC1成长率 ");
//        buffer.append(pet.getGrowlevel());
        czDLab.setBounds(200, 75, 50, 16);
        czDLab.setText("<html><u>"+formatWithoutRounding(pet.getGrowlevel())+"</u></html>");
        buffer.append("\t       #cFFD306龙骨x");
//        buffer.append("\t #cFFD306龙骨x");
        buffer.append(pet.getDragon());
        buffer.append("\t   #cFFD306超级龙之骨x");
        buffer.append(pet.getSpdragon());

        configure7 = item.get(new BigDecimal(7));

        //buffer.append("#r#cFBFFC1高突破成就: ");
        // 龙魄开关
        if("开".equals(configure7.getXdzhssx())) {
            buffer.append("#r             #c00CACA龙魄x"+pet.getLzpdragon());
            //buffer.append(pet.getSpdragon1());
            // 进阶开关
            if("开".equals(configure7.getNdslsx())) {
                buffer.append("\t   #c00CACA进阶x");
                buffer.append(pet.getCzjjd());
            }
        }
        else if("关".equals(configure7.getXdzhssx())) {
            // 进阶开关
            if("开".equals(configure7.getNdslsx())) {
                buffer.append("#r              #c00CACA进阶x");
                buffer.append(pet.getCzjjd());

            }
        }

        if ("5".equals(pet.getSsn()) || "200125".equals(pet.getSummoningid())) {
            buffer.append("  龙涎丸×");
            buffer.append(pet.getDraC());
        }
        pets = PetProperty.getPetHMASp(pet);
        sizeW = (pets[0] + "").length() + (pet.getHp() + "").length();
//        buffer.append("#r#c7DDE8C气血 ");
//        buffer.append(pets[0]);
//        buffer.append("#W(" + pet.getHp() + ") ");
//        for (int k = sizeW; k < 10; ++k) {
//            buffer.append(" ");
//        }
//        buffer.append("#c7DDE8C攻击 ");
//        buffer.append(pets[2]);
//        buffer.append("#W(" + pet.getAp() + ") ");
//        buffer.append("#r#c7DDE8C法力 ");
//        buffer.append(pets[1]);
//        buffer.append("#W(" + pet.getMp() + ") ");
//
//        for (sizeW = (k = (pets[1] + "").length() + (pet.getMp() + "").length()); k < 10; ++k) {
//            buffer.append(" ");
//        }
//        buffer.append("#c7DDE8C速度 ");
//        buffer.append(pets[3]);
//        buffer.append("#W(" + pet.getSp() + ") ");
        buffer.append("#r");
        int xw = -20;
        int yw = 40;
        hpzLab.setText("气血 "+pets[0]);
        int hzWidth = SwingUtilities.computeStringWidth(hpzLab.getFontMetrics(hpzLab.getFont()), hpzLab.getText());
        hpzLab.setBounds(175+xw, 64 + 5 + yw, hzWidth, 16);
        hpDLab.setText("<html><u>("+pet.getHp()+")</u></html>");
        hpDLab.setBounds(180+xw + hzWidth, 64 + 5 + yw, 50, 16);
        apzLab.setText("攻击 "+pets[2]);
        int azWidth = SwingUtilities.computeStringWidth(apzLab.getFontMetrics(apzLab.getFont()), apzLab.getText());
        apzLab.setBounds(310+xw, 64 + 5 + yw, azWidth, 16);
        apDLab.setBounds(315+xw +azWidth, 64 + 5 + yw, 50, 16);
        apDLab.setText("<html><u>("+pet.getAp()+")</u></html>");
        int apleng = apDLab.getText().length();
        for (int k = 0; k < apleng; k++) {
            if(k%4==0){
                buffer.append(" ");
            }
        }
        buffer.append("#r ");
        buffer.append("#r ");
        mpzLab.setText("法力 "+pets[1]);
        int mzWidth = SwingUtilities.computeStringWidth(mpzLab.getFontMetrics(mpzLab.getFont()), mpzLab.getText());
        mpzLab.setBounds(175+xw, 81 + 5 + yw, mzWidth, 16);
        mpDLab.setBounds(180+xw +mzWidth, 81 + 5 + yw, 50, 16);
        mpDLab.setText("<html><u>("+pet.getMp()+")</u></html>");
        int k;
        for (sizeW = (k = (pets[1] + "").length()); k < 6; ++k) {
            buffer.append(" ");
        }
        spzLab.setText("速度 "+pets[3]);
        int szWidth = SwingUtilities.computeStringWidth(spzLab.getFontMetrics(spzLab.getFont()), spzLab.getText());
        spzLab.setBounds(310+xw, 81 + 5 + yw, szWidth, 16);
        spDLab.setBounds(315+xw +szWidth, 81 + 5 + yw, 50, 16);
        spDLab.setText("<html><u>("+pet.getSp()+")</u></html>");
        if (pet.getTurnRount() == 4) {
            buffer.append("#r#c7DDE8C禅定 ");
            buffer.append(pets[4]);
            buffer.append("#W(0)");
        }
        buffer.append("#r#cD8AB6C内   丹 ");
        for (k = 0; k < this.nds.size(); ++k) {
            if (k != 0) {
                buffer.append("#r        ");
            }
            good4 = (Goodstable)this.nds.get(k);
            strings = good4.getValue().split("\\|");
            stringLevel = strings[2].split("\\=");
            stringLevel2 = stringLevel[1].split("\\转");
            buffer.append(good4.getGoodsname());
            buffer.append("  ");
            buffer.append(("4".equals(stringLevel2[0]) ? "点化" : (stringLevel2[0] + "转")) + stringLevel2[1]);
            buffer.append("级");
        }
        buffer.append("#r ");
        if (!StringUtil.isNullOrEmpty(pet.getLingxi())) {
            buffer.append("#r#Y灵犀等级：" + LingXiUtil.getPointCount(pet.getLingxi()) + "  开启技能格：" + LingXiUtil.getLingXiGe(pet.getLingxi()));
        }
        buffer.append("#r#c8EDEFF炼妖次数    ");
        buffer.append(pet.getAlchemynum());
        tss = null;
        lys = null;
        if (pet.getResistance() != null && !"".equals(pet.getResistance())) {
            tss = pet.getResistance().split("\\|");
        }
        if (pet.getLyk() != null && !"".equals(pet.getLyk())) {
            lys = pet.getLyk().split("\\|");
        }
        if (tss != null) {
            double t = 0.0;
            double l = 0.0;
            for (int m = 0; m < tss.length; ++m) {
                v2 = tss[m].split("=");
                t = Double.parseDouble(v2[1]);
                qz = v2[0] + "=";
                l = 0.0;
                if (lys != null) {
                    for (int j2 = 0; j2 < lys.length; ++j2) {
                        if (lys[j2] != null && lys[j2].startsWith(qz)) {
                            l = Double.parseDouble(lys[j2].split("=")[1]);
                            l = ((l < (max-30)) ? l : (max-30));
                            lys[j2] = null;
                            break;
                        }
                        if (lys[j2] != null && qz.startsWith("抗物理") && lys[j2].startsWith("物理吸收")) {
                            l = Double.parseDouble(lys[j2].split("=")[1]);
                            l = ((l < (max-30)) ? l : (max-30));
                            lys[j2] = null;
                            break;
                        }
                    }
                }
                buffer.append("#r");
                buffer.append(v2[0]);
                buffer.append(": ");
                buffer.append(t + l);
                buffer.append("(#W");
                buffer.append(t);
                buffer.append("#c8EDEFF+");
                buffer.append(l);
                buffer.append(")");
            }
        }
        if (lys != null) {
            int size = 0;
            for (int i2 = 0; i2 < lys.length; ++i2) {
                if (lys[i2] != null && !lys[i2].equals("null")) {
                    buffer.append((size % 2 == 0) ? "#r" : " ");
                    kx = lys[i2].split("=");
                    buffer.append(kx[0]);
                    buffer.append(": ");
                    buffer.append((Double.valueOf(kx[1]).doubleValue() > max) ? max : Double.valueOf(kx[1]).doubleValue());
                    ++size;
                }
            }
        }
        buffer.append("#r ");
        if(!"3".equals(Xy2Util.zzs)) {
            buffer.append("#r#Y装备:#r #r#Y觉醒技:");
            final String jx = JX((part1 != null) ? part1.getValue() : null, (part2 != null) ? part2.getValue() : null, (part3 != null) ? part3.getValue() : null);
            if (jx != null) {
                buffer.append(jx);
            }
            else {
                buffer.append("未觉醒");
            }
        }
        qm = pet.getFriendliness();
        buffer.append("#r#c8EDEFF亲密度:" + qm);
        this.richLabel.setTextSize(buffer.toString(), 255);
        this.richLabel.setBounds(155, 10, this.richLabel.getWidth(), this.richLabel.getHeight());
        if(!"3".equals(Xy2Util.zzs)) {
            for (int i3 = 0; i3 < this.labPart.length; ++i3) {
                this.labPart[i3].setBounds(195 + 30 * i3, this.richLabel.getHeight() - 60, 26, 26);
                if (i3 == 3) {
                    if (cjs != null) {
                        this.labPart[i3].setIcon((Icon)GoodsListFromServerUntil.imgpathAdaptive(cjs.getSkin(), 24, 24));
                        PetEquipMouslisten equipMouslisten = new PetEquipMouslisten(this, i3, cjs);
                        this.labPart[i3].addMouseListener((MouseListener)equipMouslisten);
                    }
                    else {
                        this.labPart[i3].setIcon(null);
                    }
                }
                else {
                    good5 = (i3 == 0) ? part1 : ((i3 == 1) ? part2 : part3);
                    if (good5 != null) {
                        this.labPart[i3].setIcon((Icon)GoodsListFromServerUntil.imgpathAdaptive(good5.getSkin(), 24, 24));
                        equipMouslisten2 = new PetEquipMouslisten(this, i3, good5);
                        this.labPart[i3].addMouseListener((MouseListener)equipMouslisten2);
                    }
                    else {
                        this.labPart[i3].setIcon(null);
                        for (MouseListener mouseListener : this.labPart[i3].getMouseListeners()) {
                            this.labPart[i3].removeMouseListener(mouseListener);
                        }
                    }
                }
            }
        }
        for (int i3 = 0; i3 < pets.length; ++i3) {
            pets[i3] = 0;
        }
        openSeal = pet.getOpenSeal().intValue();
        if (openSeal > numskll) {
            openSeal = numskll;
        }
        for (int i4 = openSeal; i4 < numskll; ++i4) {
            this.labSkillImg[i4].setVisible(false);
            this.labSkillName[i4].setVisible(false);
        }
        skills = null;
        if (pet.getPetSkills() != null && !"".equals(pet.getPetSkills())) {
            skills = pet.getPetSkills().split("\\|");
        }
        Map<String, String> qlMap = new HashMap<>();
        if (StringUtils.isNotBlank(pet.getPetSkillswl())) {
            String[] v = pet.getPetSkillswl().split("\\|");
            for (String s : v) {
                String[] n = s.split("=");
                qlMap.put(n[0], n[1]);
            }
        }
        for (int m = 0; m < openSeal; ++m) {
            if ((skills != null && m < skills.length) || (m == numskll-1 && pet.getBeastSkills() != null && !"".equals(pet.getBeastSkills()))) {
                final Skill skill = UserMessUntil.getSkillId((m == numskll-1) ? pet.getBeastSkills() : skills[m]);
                if (skill != null) {
                    this.labSkillImg[m].setIcon((Icon)this.petskillIcon(skill.getSkillid()));
                    String s = qlMap.get(skill.getSkillid() + "");
                    if (StringUtils.isNotBlank(s)) {
                        this.labSkillName[m].setText(skill.getSkillname() + "(" + s + "阶)");//启灵阶数
                    } else
                    this.labSkillName[m].setText(skill.getSkillname());
                    final int skillID = Integer.parseInt(skill.getSkillid());
                    if (skillID == 1815) {
                        pets[0] = 50;
                    }
                    else if (skillID == 1816) {
                        pets[1] = 50;
                    }
                    else if (skillID == 1817) {
                        pets[4] = 50;
                    }
                    else if (skillID == 1818) {
                        pets[3] = 50;
                    }
                    else if (skillID == 1819) {
                        pets[2] = 50;
                    }
                }
            }
            else {
                this.labSkillImg[m].setIcon((Icon)this.kaiqi);
                this.labSkillName[m].setText("已开启");
            }
            this.labSkillImg[m].setVisible(true);
            this.labSkillName[m].setVisible(true);
        }
        int openQlSeal = pet.getOpenql().intValue();
        if (openQlSeal > 6) {
            openQlSeal = 6;
        }
        for (int i5 = openQlSeal; i5 < 6; ++i5) {
            this.qlSkillImg[i5].setVisible(false);
            this.qlSkillName[i5].setVisible(false);
        }
        skillsx = null;
        if (pet.getPetQlSkills() != null && !"".equals(pet.getPetQlSkills())) {
            skillsx = pet.getPetQlSkills().split("\\|");
        }
        for (int i6 = 0; i6 < openQlSeal; ++i6) {
            if (skillsx != null && i6 < skillsx.length) {
                skillx = UserMessUntil.getSkillId(skillsx[i6]);
                if (skillx != null) {
                    this.qlSkillImg[i6].setIcon((Icon)this.petskillIcon(skillx.getSkillid()));
                    this.qlSkillName[i6].setText(skillx.getSkillname());
                    this.qlSkillImg[i6].setBounds(10, 230 + i6 * 20 + openSeal * 20, 20, 20);
                    this.qlSkillName[i6].setBounds(35, 230 + i6 * 20 + openSeal * 20, 105, 20);
                    final int skillID2 = Integer.parseInt(skillx.getSkillid());
                    if (skillID2 == 1815) {
                        pets[0] = 50;
                    }
                    else if (skillID2 == 1816) {
                        pets[1] = 50;
                    }
                    else if (skillID2 == 1817) {
                        pets[4] = 50;
                    }
                    else if (skillID2 == 1818) {
                        pets[3] = 50;
                    }
                    else if (skillID2 == 1819) {
                        pets[2] = 50;
                    }
                }
            }
            else {
                this.qlSkillImg[i6].setIcon((Icon)this.kaiqi);
                this.qlSkillName[i6].setText("启灵已开启");
                this.qlSkillImg[i6].setBounds(10, 230 + i6 * 20 + openSeal * 20, 20, 20);
                this.qlSkillName[i6].setBounds(35, 230 + i6 * 20 + openSeal * 20, 105, 20);
            }
            this.qlSkillImg[i6].setVisible(true);
            this.qlSkillName[i6].setVisible(true);
        }
        if(numskll == 9) {
            this.qilingcount.setText(pet.getOpenql() + "次");
        }
        this.gheight = 10 + this.richLabel.getHeight();
        if (180 + openSeal * 20 + openQlSeal * 20 > this.gheight) {
            this.gheight = 180 + openSeal * 20 + openQlSeal * 20;
        }
        this.gheight += 30;
        sizeW = ((pets[0] != 0 || pets[1] != 0 || pets[2] != 0 || pets[3] != 0 || pets[4] != 0) ? 2 : 1);
        array = pets;
        n = 0;
        array[n] += Integer.parseInt(pet.getGold()) / sizeW;
        array2 = pets;
        n2 = 1;
        array2[n2] += Integer.parseInt(pet.getWood()) / sizeW;
        final int[] array3 = pets;
        final int n3 = 2;
        array3[n3] += Integer.parseInt(pet.getSoil()) / sizeW;
        final int[] array4 = pets;
        final int n4 = 3;
        array4[n4] += Integer.parseInt(pet.getWater()) / sizeW;
        final int[] array5 = pets;
        final int n5 = 4;
        array5[n5] += Integer.parseInt(pet.getFire()) / sizeW;
        this.labFive[0].setText("金:" + pets[0]);
        this.labFive[1].setText("木:" + pets[1]);
        this.labFive[2].setText("土:" + pets[2]);
        this.labFive[3].setText("水:" + pets[3]);
        this.labFive[4].setText("火:" + pets[4]);
        for (int i6 = 0; i6 < 5; ++i6) {
            this.labFive[i6].setBounds(130 + i6 * 52, this.gheight - 20, 52, 30);
        }
        this.gheight += 15;
        if(pet.getQuality()!=null) {
            if("1".equals(pet.getQuality())) {
                this.gheight += 15;
            }
        }
        return this.gheight += 20;
    }

    private ImageIcon petskillIcon(final String skillid) {
        return CutButtonImage.getImage("inkImg/old/skill/wxs_" + skillid + ".png", 20, 20);
    }

    public int getGheight() {
        return this.gheight;
    }

    public static String JX(String jx1, String jx2, String jx3) {
        if (jx1 == null || jx2 == null || jx3 == null) {
            return null;
        }
        for (int i = 0; i < 3; ++i) {
            String x = (i == 0) ? jx1 : ((i == 1) ? jx2 : jx3);
            final int s1 = x.indexOf("觉醒技");
            if (s1 == -1) {
                return null;
            }
            x = x.substring(s1);
            final int s2 = x.indexOf("|");
            if (s2 != -1) {
                x = x.substring(0, s2);
            }
            if (i == 0) {
                jx1 = x;
            }
            else if (i == 1) {
                jx2 = x;
            }
            else {
                jx3 = x;
            }
        }
        final String[] jxs1 = jx1.split("\\&");
        final String[] jxs2 = jx2.split("\\&");
        final String[] jxs3 = jx3.split("\\&");
        if (!jxs1[1].equals(jxs2[1]) || !jxs1[1].equals(jxs3[1])) {
            return null;
        }
        final Skill skill = UserMessUntil.getSkillId(jxs1[1]);
        final double sld = PetEquipmentJpanel.averageMath(jxs1[2], jxs2[2], jxs3[2]).doubleValue();
        return skill.getSkillname() + "(" + sld + ")";
    }
    private Color hexToColor(String hex) {
        // 去掉可能存在的 '#' 符号
        hex = hex.replace("#", "");
        // 解析十六进制字符串
        return new Color(
                Integer.parseInt(hex.substring(0, 2), 16),
                Integer.parseInt(hex.substring(2, 4), 16),
                Integer.parseInt(hex.substring(4, 6), 16));
    }
    public static String formatWithoutRounding(String strNumber) {
        int indexOfDot = strNumber.indexOf(".");

        if (indexOfDot == -1) {
            return strNumber; // 如果没有小数点，直接返回字符串
        }

        // 截取小数点前和后两位
        String integerPart = strNumber.substring(0, indexOfDot + 1); // 包含小数点
        String decimalPart = "";

        if (indexOfDot + 2 < strNumber.length()) {
            decimalPart = strNumber.substring(indexOfDot + 1, Math.min(indexOfDot + 4, strNumber.length()));
        } else if (indexOfDot + 1 < strNumber.length()) {
            decimalPart = strNumber.substring(indexOfDot + 1);
        }

        return integerPart + decimalPart; // 合并整数部分和小数部分
    }
}
